Skip to main content

WrapOperator

Type

operator

Summary

Wrap operator.

Syntax

<Left> wrap <Right>

Description

Use wrap to ensure the value of a variable stays within a specified range. For x,y > 0, successive values of x wrap y cycle through the sequence 1, 2, ..., y.

Parameters

NameTypeDescription

Left

An expression that evaluates to a number.

Right

An expression that evaluates to a number.

Examples

variable tVar as Number
put 5 wrap 3 into tVar -- tVar contains 2
variable tVar as Number
put -3 wrap 3 into tVar -- tVar contains -3

Value

NameTypeDescription

return

If x >= 0, then x wrap y returns ((x-1) mod abs(y)) + 1. If x < 0, then x wrap y returns -((x-1) mod abs(y)) + 1.

Thank you for your feedback!

Was this page helpful?